#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime time1 = ui->dateTimeEdit->dateTime();
    QDateTime time2 = ui->dateTimeEdit_2->dateTime();

    //int days = time1.daysTo(time2);
    int secs = time1.secsTo(time2);
    int hours = (secs/3600)%24;
    int days = (secs/3600)/24;

    ui->label->setText(QString("相差")+QString::number(days)+"天"+QString::number(hours)+"小时");
}
